package com.czl.module_storehouse.mvp.presenter;

import com.czl.module_base.bean.ListBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_base.mvp.presenter.BasePresenter;
import com.czl.module_base.observer.AbsHandleSubscriber;
import com.czl.base.data.bean.tengyun.ReceiveBean;
import com.czl.module_storehouse.mvp.model.ReceiveHomeModel;
import com.czl.module_storehouse.mvp.view.ReceiveHomeView;

/**
 * @author by xubin,
 * @date on 2022/1/25.
 * PS: Not easy to write code, please indicate.
 */
public class ReceiveHomePresenter extends BasePresenter<ReceiveHomeModel, ReceiveHomeView> {

    private int mPageNo = 1;

    @Override
    public int getPageNo() {
        return mPageNo;
    }

    public void getNeedDealtReceiveList(boolean refresh) {
        if (refresh) {
            mPageNo = 1;
        }
        doSubscribe(mModel.getNeedDealtReceiveList(mPageNo), new AbsHandleSubscriber<HttpResponse<ListBean<ReceiveBean>>>(mView) {
            @Override
            public void onSuccess(HttpResponse<ListBean<ReceiveBean>> listBeanHttpResponse) {
                mView.showData(listBeanHttpResponse.getData());
            }
        }, true);
    }

    public void getDealtReceiveList(boolean refresh) {
        if (refresh) {
            mPageNo = 1;
        }
        doSubscribe(mModel.getDealtReceiveList(mPageNo), new AbsHandleSubscriber<HttpResponse<ListBean<ReceiveBean>>>(mView) {
            @Override
            public void onSuccess(HttpResponse<ListBean<ReceiveBean>> listBeanHttpResponse) {
                mView.showData(listBeanHttpResponse.getData());
                mPageNo++;
            }
        }, true);
    }
}
